package com.ruoyi.web.controller.bus;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.bus.domain.WitRouteSite;
import com.ruoyi.bus.service.IWitRouteSiteService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 站点路线Controller
 * 
 * @author caiyanshan
 * @date 2021-04-14
 */
@RestController
@RequestMapping("/bus/routeSite")
public class WitRouteSiteController extends BaseController
{
    @Autowired
    private IWitRouteSiteService witRouteSiteService;

    /**
     * 查询站点路线列表
     */
    @PreAuthorize("@ss.hasPermi('bus:routeSite:list')")
    @GetMapping("/list")
    public TableDataInfo list(WitRouteSite witRouteSite)
    {
        startPage();
        List<WitRouteSite> list = witRouteSiteService.selectWitRouteSiteList(witRouteSite);
        return getDataTable(list);
    }

    /**
     * 导出站点路线列表
     */
    @PreAuthorize("@ss.hasPermi('bus:routeSite:export')")
    @Log(title = "站点路线", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(WitRouteSite witRouteSite)
    {
        List<WitRouteSite> list = witRouteSiteService.selectWitRouteSiteList(witRouteSite);
        ExcelUtil<WitRouteSite> util = new ExcelUtil<WitRouteSite>(WitRouteSite.class);
        return util.exportExcel(list, "routeSite");
    }

    /**
     * 获取站点路线详细信息
     */
    @PreAuthorize("@ss.hasPermi('bus:routeSite:query')")
    @GetMapping(value = "/{routeId}")
    public AjaxResult getInfo(@PathVariable("routeId") Long routeId)
    {
        return AjaxResult.success(witRouteSiteService.selectWitRouteSiteById(routeId));
    }

    /**
     * 新增站点路线
     */
    @PreAuthorize("@ss.hasPermi('bus:routeSite:add')")
    @Log(title = "站点路线", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WitRouteSite witRouteSite)
    {
        return toAjax(witRouteSiteService.insertWitRouteSite(witRouteSite));
    }

    /**
     * 修改站点路线
     */
    @PreAuthorize("@ss.hasPermi('bus:routeSite:edit')")
    @Log(title = "站点路线", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WitRouteSite witRouteSite)
    {
        return toAjax(witRouteSiteService.updateWitRouteSite(witRouteSite));
    }

    /**
     * 删除站点路线
     */
    @PreAuthorize("@ss.hasPermi('bus:routeSite:remove')")
    @Log(title = "站点路线", businessType = BusinessType.DELETE)
	  @DeleteMapping("/{routeIds}")
    public AjaxResult remove(@PathVariable Long[] routeIds)
    {
        return toAjax(witRouteSiteService.deleteWitRouteSiteByIds(routeIds));
    }
}
